package midas.mw.crt.presence;

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;

import midas.mw.cfg.CfgError;
import midas.mw.cfg.CfgLogging;
import midas.mw.cfg.log.Logger;
import midas.mw.crt.CrtImpl;
import midas.mw.crt.MD.PriorityTable;
import midas.mw.crt.common.IPMessage;
import midas.mw.crt.interfaces.CrtCallback;

/**
 * This class manages the thread responsible of sending messages
 */
public class NokiaPresenceThread extends Thread
{
    /**
	 * Instance of the CRT running in the node
	 */
	CrtImpl crt = null;
	
	/**
	 * Time to wait
	 */
	private long waitingTime 		= 30000;
	
	/**
	 * Constructor - initiate local variables
	 * @param crt Instance of the CRT running in the node
	 */
	public NokiaPresenceThread (CrtImpl crt)
	{		
		CfgLogging.logEvent(CfgLogging.LOG_MCALL, Logger.COMPONENT_CRT, CfgLogging.SEV_DEBUG, "NokiaNodesPresenceThread(CrtImpl)");		
		
		this.crt 			= crt;		
	}
	
	/**
	 * Overriding the run method of class Thread
	 */
	public void run()
	{
		CfgLogging.logEvent(CfgLogging.LOG_MCALL, Logger.COMPONENT_CRT, CfgLogging.SEV_DEBUG, "NokiaPresenceThread.run()");		
		
		while (true)
		{
			crt.getJxtaPlatform().getNodePresence().notifyDissapearedNodes();
			
			try {
				sleep(waitingTime);
			} catch (InterruptedException ie){ie.printStackTrace();}
		}								
	}	
}
